package com.ruoyi.project.channel.channelAccountWb.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.channel.channelAccountWb.domain.ChannelAccountWb;
import com.ruoyi.project.channel.channelAccountWb.service.IChannelAccountWbService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 微博收款信息操作处理
 * 
 * @author CAIN
 * @date 2019-12-04
 */
@Controller
@RequestMapping("/channel/channelAccountWb")
public class ChannelAccountWbController extends BaseController
{
    private String prefix = "channel/channelAccountWb";
	
	@Autowired
	private IChannelAccountWbService channelAccountWbService;
	
	@GetMapping("/{orderId}")
	public String channelAccountWb(@PathVariable("orderId") String orderId, ModelMap mmap)
	{
		mmap.put("orderId",orderId);
	    return "channel/channelOrder/channelAccountWb";
	}
	
	/**
	 * 查询微博收款列表
	 */
	@PostMapping("/list/{orderId}")
	@ResponseBody
	public TableDataInfo list(@PathVariable("orderId") String orderId, ChannelAccountWb channelAccountWb)
	{
		startPage();
		channelAccountWb.setOrderId(orderId);
        List<ChannelAccountWb> list = channelAccountWbService.selectChannelAccountWbList(channelAccountWb);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出微博收款列表
	 */
    @PostMapping("/export/{orderId}")
    @ResponseBody
    public AjaxResult export(@PathVariable("orderId") String orderId,ChannelAccountWb channelAccountWb)
    {
		channelAccountWb.setOrderId(orderId);
    	List<ChannelAccountWb> list = channelAccountWbService.selectChannelAccountWbList(channelAccountWb);
        ExcelUtil<ChannelAccountWb> util = new ExcelUtil<ChannelAccountWb>(ChannelAccountWb.class);
        return util.exportExcel(list, "channelAccountWb");
    }
	
	/**
	 * 新增微博收款
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存微博收款
	 */
	@RequiresPermissions("channel:channelAccountWb:add")
	@Log(title = "微博收款", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ChannelAccountWb channelAccountWb)
	{		
		return toAjax(channelAccountWbService.insertChannelAccountWb(channelAccountWb));
	}

	/**
	 * 修改微博收款
	 */
	@GetMapping("/edit/{wbId}")
	public String edit(@PathVariable("wbId") Long wbId, ModelMap mmap)
	{
		ChannelAccountWb channelAccountWb = channelAccountWbService.selectChannelAccountWbById(wbId);
		mmap.put("channelAccountWb", channelAccountWb);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存微博收款
	 */
	@RequiresPermissions("channel:channelAccountWb:edit")
	@Log(title = "微博收款", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ChannelAccountWb channelAccountWb)
	{		
		return toAjax(channelAccountWbService.updateChannelAccountWb(channelAccountWb));
	}
	
	/**
	 * 删除微博收款
	 */
	@RequiresPermissions("channel:channelAccountWb:remove")
	@Log(title = "微博收款", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(channelAccountWbService.deleteChannelAccountWbByIds(ids));
	}
	
}
